﻿using LiuQiuRong.Chat.Infrastructures.Dependencies;
using LiuQiuRong.Chat.Infrastructures.Models;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace LiuQiuRong.Chat.Businesses
{
    public partial interface IBaseService<TEntity, TDto> : IService where TEntity : class, IEntity, new() where TDto : class, IDto, new()
    {
        HandleResult Result(string output = "success", object extras = default);

        TDto GetById<TKey>(TKey id);
        TDto GetByExpression(Expression<Func<TEntity, bool>> expression);

        (int, HandleResult) Insert(TDto dto);

        (int, HandleResult) Insert<T, TMap>(TMap dto) where T : class, new() where TMap : class, new();

        (int, HandleResult) Update(TDto dto);

        (int, HandleResult) Update<T, TMap>(TMap dto) where T : class, new() where TMap : class, new();

        (int, HandleResult) UpdateColumns(TDto dto, Expression<Func<TEntity, object>> columns);

        (int, HandleResult) UpdateColumns<T, TMap>(TMap dto, Expression<Func<T, object>> columns) where T : class, new() where TMap : class, new();

        (int, HandleResult) Delete<TKey>(TKey id);

        bool Any(Expression<Func<TEntity, bool>> expression);

        IEnumerable<TDto> GetList(Expression<Func<TEntity, bool>> expression, string orderBy = null);

        IEnumerable<TDto> GetList(string expression, string orderBy = null);

        IEnumerable<TDto> GetListByPage(Expression<Func<TEntity, bool>> expression, string orderBy, int pageIndex, int pageSize, ref int records, ref int totalPage);

        IEnumerable<TDto> GetListByPage(string expression, string orderBy, int pageIndex, int pageSize, ref int records, ref int totalPage);
    }
}
